using System;
using System.Collections;
using System.Web.Caching;

namespace WebMonitor.Http.Impl {
    public class CacheAdapter : ICache {
        private readonly Cache cach;

        public CacheAdapter(Cache cach) {
            this.cach = cach;
        }

        public IDictionaryEnumerator GetEnumerator() {
            return cach.GetEnumerator();
        }

        public object Get(string key) {
            return cach.Get(key);
        }

        public void Insert(string key, object value) {
            cach.Insert(key, value);
        }

        public void Insert(string key, object value, CacheDependency dependencies) {
            cach.Insert(key, value, dependencies);
        }

        public void Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration) {
            cach.Insert(key, value, dependencies, absoluteExpiration, slidingExpiration);
        }

        public void Insert(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) {
            cach.Insert(key, value, dependencies, absoluteExpiration, slidingExpiration, priority, onRemoveCallback);
        }

        public object Add(string key, object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) {
            return cach.Add(key, value, dependencies, absoluteExpiration, slidingExpiration, priority, onRemoveCallback);
        }

        public object Remove(string key) {
            return cach.Remove(key);
        }

        public int Count {
            get { return cach.Count; }
        }

        public object this[string key] {
            get { return cach[key]; }
            set { cach[key] = value; }
        }

        public TimeSpan NoSlidingExpiration {
            get { return Cache.NoSlidingExpiration; }
        }

        public DateTime NoAbsoluteExpiration {
            get { return Cache.NoAbsoluteExpiration; }
        }

        IEnumerator IEnumerable.GetEnumerator() {
            return GetEnumerator();
        }
    }
}